<?php

class MapviewController extends Controller
{
	public function actionShowonmap($id, $optVal)
	{
		$projectVal = Project::model()->findByPk($id);
		$this->render('showonmap',array('project'=>$projectVal,'opt'=>$optVal));
	}

	public function actionIndex()
	{
		//if(isset($_GET['projname']) ||isset($_GET['city'])||isset($_GET['province']))
		if(isset($_GET['projname'],$_GET['city'],$_GET['province']))
		{
			if(isset($_GET['projname'])){ $sql= '`name` like "'. $_GET['projname'].'%"';}
			/*elseif(isset($_GET['city']))
			{			
				$sql= $sql . 'or city like "'.$_GET['city'].'%"';
			}
			elseif(!isset($_GET['projname'])&& isset($_GET['city']))
			{
				$sql='city like "'.$_GET['city'].'%"';
			}
			elseif(isset($_GET['province']))
			{			
				$sql= $sql . 'or province like "'.$_GET['province'].'%"';
			}
			elseif(!isset($_GET['city'])&& isset($_GET['city']))
			{
				$sql='province like "' .$_GET['province'] .'%"';
			}
			print_r($sql);exit;*/
			$projects = Project::model()->findAll($sql);
		}else{
			$projects = Project::model()->findAll();
		}
		$model = new Guestbook();
		$this->render('index',array('projects'=>$projects, 'model'=>$model));
	}

	// Uncomment the following methods and override them if needed
	/*
	public function filters()
	{
		// return the filter configuration for this controller, e.g.:
		return array(
			'inlineFilterName',
			array(
				'class'=>'path.to.FilterClass',
				'propertyName'=>'propertyValue',
			),
		);
	}

	public function actions()
	{
		// return external action classes, e.g.:
		return array(
			'action1'=>'path.to.ActionClass',
			'action2'=>array(
				'class'=>'path.to.AnotherActionClass',
				'propertyName'=>'propertyValue',
			),
		);
	}
	*/
}